<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0px;
            padding: 0px;
            list-style: none;
        }
        ul{
          
            overflow: hidden;
        }
        li{
            float: left;
            width:120px;
            text-align: center;
            height: 30px;
           
            line-height: 30px;
            cursor: pointer;
        }
        div{
            width: 400px;
            height: 300px;
            text-align: center;
            line-height: 300px;
            border:1px solid red;
            
            display: none;
        }
     
      
        li.current{
            background:lime;
            color:white;
        }
        div.current{
        
            display: block;
        }
    </style>
</head>
<body>
    <ul>
        <li class="current">花园宝宝</li>
        <li>天线宝宝</li>
        <li>小羊肖恩</li>
        <li>海绵宝宝</li>
        <li>顶楼</li>
        <li>快乐星球</li>
    </ul>
    <section>
        <div class="current">花园宝宝内容</div>
        <div>天线宝宝内容</div>
        <div>小羊肖恩内容</div>
        <div>海绵宝宝内容</div>
        <div>顶楼内容</div>
        <div>快乐星球内容</div>
    </section>

    <script>
      
        var tags=document.getElementsByTagName('li');
        var boxs=document.getElementsByTagName('div');
       
        for(var i=0;i<tags.length;i++){
           
            tags[i].index=i;
           
            tags[i].onclick=function(){
            
                for(var j=0;j<tags.length;j++){
                    tags[j].className=''
                    boxs[j].className=''
                }
                
                this.className='current';
                
                var n=this.index;
                boxs[n].className='current'
            }
        }
    </script>
</body>
</html>